{{ $related := (where site.RegularPages "Type" "in" site.Params.mainSections).Related . | first 3 }}
{{ with $related }}
<div class="related-content">
  <h3>Related Posts</h3>
  <ul>
    {{ range . }}
    <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
    {{ end }}
  </ul>

</div>
{{ end }}